package com.cl.ks.flow.enums;

public enum NodeHandlerEnum {

    START("start", "开始"),
    DATA_SOURCE("dataSource", "数据源"),
    PUSH_CLUE("pushClue", "推送线索"),
    DATA_TYPE("dataType", "数据资源"),
    SQL_QUERY("sqlQuery", "SQL查询"),
    KS_RULE("ksRule", "模型"),
    KS_RULE_INVOKE("ksRuleInvoke", "规则引用"),
    CREATE_TABLE("createTable", "输出表"),
    CREATE_TABLE_PUSH_CLUE("createTablePushClue", "业务线索推送"),
    KS_FLOW_GRAPH_CHILD("ksFlowGraphChild", "子流程"),
    KS_FLOW_GRAPH_CHILD_GROUP_BY("ksFlowGraphChildGroupBy", "分组子流程"),
    SPARK_NODE("sparkNode", "操作"),

    PERSIST_DATA("persistData", "持久化数据"),
    READ_PERSIST_DATA("readPersistData", "读取持久化数据"),
    END("end", "结束");

    private final String code;
    private final String nodeName;

    NodeHandlerEnum(String code, String nodeName) {
        this.code = code;
        this.nodeName = nodeName;
    }
    public static NodeHandlerEnum getNodeHandlerByCode(String code){
        for (NodeHandlerEnum e : NodeHandlerEnum.values()){
            if (e.getCode().equals(code)){
                return e;
            }
        }
        return null;
    }
    public static NodeHandlerEnum getNodeHandlerByNodeName(String name){
        for (NodeHandlerEnum e : NodeHandlerEnum.values()){
            if (e.getNodeName().equals(name)){
                return e;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getNodeName() {
        return nodeName;
    }
}
